var a = require("../../utils/util.js"), t = getApp();

Page({
    data: {
        id: "",
        imagewidth: 0,
        imageheight: 0,
        baseUrl: t.globalData.baseUrl,
        banner: []
    },
    imageLoad: function(t) {
        var e = a.imageUtil(t);
        this.setData({
            imagewidth: e.imageWidth,
            imageheight: e.imageHeight
        });
    },
    onLoad: function(a) {
        this.setData({
            nickName: t.globalData.nickName,
            avatarUrl: t.globalData.avatarUrl,
            id: a.id
        });
        var e = t.globalData.urlBase + "server/serverDetail";
        this.getinitData(e);
    },
    getinitData: function(a) {
        var e = this;
        wx.request({
            url: a,
            data: {
                lng: t.globalData.lng,
                lat: t.globalData.lat,
                serverId: e.data.id,
                userId: t.globalData.userId
            },
            method: "POST",
            header: {
                "content-type": "application/x-www-form-urlencoded"
            },
            success: function(a) {
                var t = JSON.parse(a.data);
                0 != t.code ? wx.showToast({
                    title: t.msg,
                    icon: "none",
                    duration: 2e3
                }) : e.setData({
                    store: t.store,
                    server: t.serverDetail,
                    banners: t.serverDetail.imgs.split(",")
                });
            }
        });
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    getBaseData: function(a) {},
    onShareAppMessage: function() {},
    openMap: function() {
        var a = this;
        wx.openLocation({
            latitude: parseFloat(a.data.store.lat),
            longitude: parseFloat(a.data.store.lng),
            name: a.data.store.name,
            address: a.data.store.address
        });
    },
    sub: function(a) {
        var e = this;
        t.globalData.yuyueTime;
        t.globalData.serBegintime = a.currentTarget.dataset.begintime, t.globalData.serEndtime = a.currentTarget.dataset.endtime, 
        t.globalData.serverId = e.data.id, t.globalData.serDetail.store = e.data.store, 
        t.globalData.serDetail.server = e.data.server, console.log(e.data.id), wx.navigateTo({
            url: "../cproject/cproject"
        });
    }
});